import { ref } from 'vue'
import { empPageSelecct } from '@/api/organize'
import { CustomerServiceOptions } from './types'

/**
 * 获取客服下拉选项架子啊
 */
const getCustomerServiceOptionsLoading = ref(false)

/**
 * 客服下拉选项
 */
const customerServiceOptions = ref<Array<CustomerServiceOptions>>([])

/**
 * 获取客服下拉选项方法
 * @param {string} keyword - 搜索关键字
 */
const getCustomerServiceOptions = async (keyword: string) => {
  getCustomerServiceOptionsLoading.value = true
  const res = await empPageSelecct({
    limit: 0,
    name: keyword,
    page: 0,
  })
  res.data.success && (customerServiceOptions.value = res.data.data.rows)
  getCustomerServiceOptionsLoading.value = false
}

export default {
  customerServiceOptions,
  getCustomerServiceOptionsLoading,
  getCustomerServiceOptions,
}
